// lang
package lang

import (
	"log"
	"swim/etc"
	"swim/util/config"
)

var (
	langCnf config.Configer
)

func init() {
	iniconf, err := config.NewConfig("ini", etc.LanguageName)
	if err != nil {
		log.Fatal(err)
		return
	}
	langCnf = iniconf
}

func GetText(strKey, lang string) string {
	if lang == "" {
		lang = "cn"
	}
	key := lang + "::" + strKey
	return langCnf.DefaultString(key, "")
}

func CheckLang(sLang string) bool {
	bRet := false
	langArray := []string{"cn", "en"}
	for _, s := range langArray {
		if sLang == "" || s == sLang {
			bRet = true
			break
		}
	}
	return bRet
}
